//
//  MOFSCollectionViewCell.m
//  fitnessmanage
//
//  Created by wujian on 2017/11/27.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "MOFSCollectionViewCell.h"

@implementation MOFSCollectionViewCell

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = CSWhiteColor;
        
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.numberOfLines = 2;
        titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        titleLabel.font = MidBigFont;
        [self addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        UIButton *checkBtn = [[UIButton alloc] init];
        [checkBtn setImage:@"pop_icon_no_Selected"];
        [checkBtn setSelectedImage:@"pop_icon_Selected"];
        [self addSubview:checkBtn];
        self.checkBtn = checkBtn;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{

    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self).offset(20);
        
        make.centerY.mas_equalTo(self);
        
        make.right.mas_equalTo(self.checkBtn.mas_left).offset(-5);
    }];
    
    [self.checkBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(self);
        
        make.right.mas_equalTo(self).offset(-5);
        
        make.width.height.mas_equalTo(10);
    }];
    
}

@end

@implementation MOFSHeaderReusableView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = CSWhiteColor;
                        
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.font = BoldMidBigFont;
        [self addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        //choseBtn
        UIButton *choseBtn = [[UIButton alloc] init];
        [choseBtn setImage:@"tjhykzl_icon_r_arrow"];
        [choseBtn setSelectedImage:@"pop_icon_d_arrow"];
        [self addSubview:choseBtn];
        self.choseBtn = choseBtn;
        
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = LineBackGroundColor;
        [self addSubview:lineView];
        self.lineView = lineView;
        
        UIButton *headBtn = [[UIButton alloc] init];
        [self addSubview:headBtn];
        self.headBtn = headBtn;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self).offset(10);
        
        make.centerY.mas_equalTo(self);
    }];
    
    
    [self.choseBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.titleLabel);
        
        make.right.mas_equalTo(self).offset(-5);
    }];
    
    [self.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self);
        
        make.left.mas_equalTo(self.titleLabel);
        
        make.right.mas_equalTo(self).offset(-20);
        
        make.height.mas_equalTo(1);
    }];
    
    [self.headBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.mas_equalTo(self);
    }];
}

-(void)setSection:(NSInteger)section{
 
    if (section == 1) {

        self.lineView.hidden = NO;
    }
    else{

        self.lineView.hidden = YES;
    }
}

@end
